#pragma once

class CConfiguration
{
private:
	CString m_strFileName;

	CString m_strInputDump;
	CString m_strOutputDump;

	ULONG64 m_nPrescanMin;
	ULONG64 m_nLinescan0;
	ULONG64 m_nLinescan0_min;
	ULONG64 m_nLinescan0_max;
	ULONG64 m_nReversal0;
	ULONG64 m_nReversal0_min;
	ULONG64 m_nReversal0_max;
	ULONG64 m_nLinescan;
	ULONG64 m_nLinescan_min;
	ULONG64 m_nLinescan_max;
	ULONG64 m_nReversal;
	ULONG64 m_nReversal_min;
	ULONG64 m_nReversal_max;

	LONG64 m_nDataWhite;
	LONG64 m_nDataBlack;
	LONG64 m_nSyncOn;
	LONG64 m_nSyncOff;

public:

	CConfiguration(void);

	void Load(const CString & strFileName);
	void Save(const CString & strFileName = _T("")) const;

	inline ULONG64 GetPrescanMin(void) const { return m_nPrescanMin; }
	inline ULONG64 GetLinescan0(void) const     { return m_nLinescan0; }
	inline ULONG64 GetLinescan0_min(void) const { return m_nLinescan0_min; }
	inline ULONG64 GetLinescan0_max(void) const { return m_nLinescan0_max; }
	inline ULONG64 GetReversal0(void) const     { return m_nReversal0; }
	inline ULONG64 GetReversal0_min(void) const { return m_nReversal0_min; }
	inline ULONG64 GetReversal0_max(void) const { return m_nReversal0_max; }
	inline ULONG64 GetLinescan(void) const     { return m_nLinescan; }
	inline ULONG64 GetLinescan_min(void) const { return m_nLinescan_min; }
	inline ULONG64 GetLinescan_max(void) const { return m_nLinescan_max; }
	inline ULONG64 GetReversal(void) const     { return m_nReversal; }
	inline ULONG64 GetReversal_min(void) const { return m_nReversal_min; }
	inline ULONG64 GetReversal_max(void) const { return m_nReversal_max; }

	double GetResampleRate(void) const;

	inline LONG64 GetDataWhite(void) const    { return m_nDataWhite; }
	inline LONG64 GetDataBlack(void) const    { return m_nDataBlack; }

	inline BYTE NormalizeData(const LONG64 & d) const
	{
		const double t = 255.0 * (d - m_nDataBlack) / (m_nDataWhite - m_nDataBlack);
		return t > 255 ? 255 : t < 0 ? 0 : BYTE(t);
	}

	inline LONG64 GetSyncOn(void) const    { return m_nSyncOn; }
	inline LONG64 GetSyncOff(void) const   { return m_nSyncOff; }
	inline LONG64 GetSyncThreshold(void) const   { return (m_nSyncOn + m_nSyncOff) / 2; }

	inline const CString & GetInputDump(void) const   { return m_strInputDump; }
	inline const CString & GetOutputDump(void) const  { return m_strOutputDump; }
};
